'use strict';

const Controller = require('egg').Controller;

let studentList = [
        {
            id:"1",
            name:"小明",
            achievement:"88"
        },
        {
            id:"2",
            name:"小刚",
            achievement:"99"
        },
    ]
class StudentsController extends Controller {
    async index() {
        this.ctx.body = studentList
    }

    async create(){
        let student = this.ctx.request.body.student;
        studentList.push(student)
        this.ctx.body = true
    }

    async destory(){
        let id = this.ctx.params.id;
        studentList.splice(id,1)
        this.ctx.body = true
    }
}

module.exports = StudentsController;
